import { IPSSysContent } from './ipssys-content';
import { IPSSysContentCat } from './ipssys-content-cat';
import { IPSSystemModule } from '../system/ipssystem-module';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSSysContentCatImpl extends PSModelObjectImpl implements IPSSysContentCat {
  get catTag(): string {
    return this.M.catTag;
  }

  get catTag2(): string {
    return this.M.catTag2;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected pssyscontents: IPSSysContent[] | null = null;

  getPSSysContents(): IPSSysContent[] | null {
    if (this.pssyscontents == null) {
      this.pssyscontents = this.fillChildListModel(this.M.getPSSysContents, 'res.IPSSysContent') as IPSSysContent[];
    }
    return this.pssyscontents;
  }

  get psSysContents(): IPSSysContent[] | null {
    return this.getPSSysContents();
  }

  findPSSysContent(objKey: any): IPSSysContent | null {
    return this.getPSModel5('res.IPSSysContent', this.getPSSysContents(), objKey) as IPSSysContent;
  }

  protected pssystemmodule: IPSSystemModule | null = null;

  getPSSystemModule(): IPSSystemModule | null {
    if (this.pssystemmodule != null) return this.pssystemmodule;
    const value = this.M.getPSSystemModule;
    if (value == null) {
      return null;
    }
    this.pssystemmodule = this.getPSModel4('system.IPSSystemModule', value, 'getPSSystemModule') as IPSSystemModule;
    return this.pssystemmodule;
  }

  get psSystemModule(): IPSSystemModule | null {
    return this.getPSSystemModule();
  }

  getPSSystemModuleMust(): IPSSystemModule {
    const value = this.getPSSystemModule();
    if (value == null) {
      throw new Error('未指定系统模块');
    }
    return value;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSSysContentCatImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'res.IPSSysContentCat') return true;
    return super.instanceof(cls);
  }
}
